#!/bin/sh
SOLR_URL="http://localhost:8080/solr/update"
EXIST_URL="http://localhost:8080/orbeon/exist/rest/db/numishare"

echo "Enter id number: "
read i
curl $EXIST_URL/vra/$i.xml -o $i.xml -s
if grep -q "<vra" $i.xml; then
	echo "Transforming $i"
	java -jar saxon/saxon9.jar -xi:on -s $i.xml -xsl:../cocoon/xslt/vra_to_solr.xsl > site_index/add_$i.xml
	echo Posting file $i to $SOLR_URL
	curl $SOLR_URL --data-binary @site_index/add_$i.xml -H 'Content-type:text/xml; charset=utf-8' 
	echo
	curl $SOLR_URL --data-binary '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
	echo
	rm $i.xml
else
	echo "This id does not exist!"
	rm $i.xml
	echo
fi
